package com.itheima.kafka.boot;

import com.alibaba.fastjson.JSON;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @Description:
 * @Version: V1.0
 */
@Component
public class HelloListener {

//    @KafkaListener(topics = "boot-topic")
//    public void reciveMessage(ConsumerRecord<?, ?> record) {
//
//        Optional<? extends ConsumerRecord<?, ?>> optional = Optional.ofNullable(record);
//        if (optional.isPresent()) {
//            ConsumerRecord<?, ?> consumerRecord = optional.get();
//
//            String value = (String) consumerRecord.value();
//            System.out.println(value);
//        }
//
//    }

//    @KafkaListener(topics = "boot-topic")
//    public void reciveMessage(String msg) {
//        System.out.println(msg);
//    }

    @KafkaListener(topics = "boot-topic")
    public void reciveMessage(String msgMap) {
        Map map = JSON.parseObject(msgMap, Map.class);
        System.out.println(map);
    }

}
